<template>
  <button @click="loginReq">登录</button>
  <button @click="loadUserInfo">个人车辆信息</button>
</template>

<!-- 
用户账号：16617320092
密码：123456
车辆VI：8klYgGHPgH7UHmz
充电桩编号：nGVSY28988546 
-->
<script setup>
  import http from '@/http/index.js'
  import {setStorage} from '@/utils/storage.js'
  
  const loginUrl = '/dev-api/login'
  const userInfo = '/dev-api/getInfo'
  
/**
 * 登录请求
 */
  async function loginReq(){
    console.log('登录请求：');
    const data = {
      "username":"16617320092",
      "password":"123456"
    }
    const loginRes = await http.post(loginUrl, data)
    //保存token
    if(loginRes.token)
      setStorage('token', loginRes.token)
  }
  /**
   * 个人和车的信息
   */
  async function loadUserInfo(){
    console.log('用户信息请求：');
    const userInfoRes = await http.get(userInfo)
  }
</script>

<style>
</style>